import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';

@Entity('users')
export class User {
  @ApiProperty({ description: '用户ID' })
  @PrimaryGeneratedColumn()
  id: number;

  @ApiProperty({ description: '用户名' })
  @Column({ unique: true, length: 50 })
  username: string;

  @ApiProperty({ description: '密码' })
  @Column({ length: 255 })
  password: string;

  @ApiProperty({ description: '昵称' })
  @Column({ length: 100, nullable: true })
  nickname: string;

  @ApiProperty({ description: '邮箱' })
  @Column({ length: 100, nullable: true })
  email: string;

  @ApiProperty({ description: '手机号' })
  @Column({ length: 20, nullable: true })
  phone: string;

  @ApiProperty({ description: '头像' })
  @Column({ length: 255, nullable: true })
  avatar: string;

  @ApiProperty({ description: '状态：0-禁用，1-启用' })
  @Column({ default: 1 })
  status: number;

  @ApiProperty({ description: '微信openid' })
  @Column({ length: 100, nullable: true })
  openid: string;

  @ApiProperty({ description: '微信unionid' })
  @Column({ length: 100, nullable: true })
  unionid: string;

  @ApiProperty({ description: '微信session_key' })
  @Column({ length: 100, nullable: true })
  sessionKey: string;

  @ApiProperty({ description: '创建时间' })
  @CreateDateColumn()
  createdAt: Date;

  @ApiProperty({ description: '更新时间' })
  @UpdateDateColumn()
  updatedAt: Date;
}

